<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class ProjectCapitalize extends Model
{
    use HasFactory;

    protected $fillable = ['amount','project_id','gap','usage_days','usage_start_date','repayment_date','interest','remarks'];

    const POSTONLY = ['amount','project_id','gap','usage_days','usage_start_date','repayment_date','interest','remarks'];

    protected function serializeDate(\DateTimeInterface $date)
    {
        return $date->format($this->dateFormat ?: 'Y-m-d H:i:s');
    }

    public function project()
    {
        return $this->hasOne(Project::class,'id','project_id')->select('id','title','status');
    }

    public function capitalizes()
    {
        return $this->hasMany(Capitalize::class);
    }
}
